package cn.xinzhi.servlet;

import cn.xinzhi.dao.Impl.Yh_goodsDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "MailServlet")
public class MailServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        request.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        String fna=request.getParameter("fname");
        String fnu=request.getParameter("fnumder") ;
        String fs=request.getParameter("fsite");
        String sna=request.getParameter("sname") ;
        String snu=request.getParameter("snumder");
        String ss=request.getParameter("ssite") ;
        Yh_goodsDaoImpl yh_goodsDao=new Yh_goodsDaoImpl();
        int conut = yh_goodsDao.goods(fna,fnu,fs,sna,snu,ss);
        if (conut!=0){
            response.sendRedirect(" index.jsp ");
        }else {
            response.sendRedirect("info.jsp");
        }


        out.flush();
        out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
